package generatepath;

import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;

import org.apache.commons.collections.map.MultiKeyMap;

import calcul.CalculatePDV;
import enums.CableType;

public class Graph {
    private Map<String, LinkedHashSet<String>> map = new HashMap();
    public static MultiKeyMap multiKeyMapCableTypeLength = new MultiKeyMap();
    
    public void addEdge(String node1, String node2, CableType cableType, int length ) {
    	CableTypeLengthValuesPair cableTypeLengthValuesPair = new CableTypeLengthValuesPair(length, cableType);
        LinkedHashSet<String> adjacent = map.get(node1);
        multiKeyMapCableTypeLength.put(node1, node2, cableTypeLengthValuesPair);
        if(adjacent==null) {
            adjacent = new LinkedHashSet();
            map.put(node1, adjacent);
        }
        adjacent.add(node2);
    }

    public void addTwoWayVertex(String node1, String node2, CableType cb, int length) {
        addEdge(node1, node2, cb, length);
        addEdge(node2, node1, cb, length);
    }

    public boolean isConnected(String node1, String node2) {
        Set adjacent = map.get(node1);
        if(adjacent==null) {
            return false;
        }
        return adjacent.contains(node2);
    }

    public LinkedList<String> adjacentNodes(String last) {
        LinkedHashSet<String> adjacent = map.get(last);
        if(adjacent==null) {
            return new LinkedList();
        }
        return new LinkedList<String>(adjacent);
    }
    public MultiKeyMap getMultiKeyMapCableTypeLength(){
    	return multiKeyMapCableTypeLength;
    }
}
